# _*_ coding: UTF-8 _*_
# @Time     : 2021/10/25 15:05
# @Author   : 郑鲁明
# @Site     : http://www.hzdledu.cn/
# @File     : practice.py
# @Software : PyCharm

# 1.获取字符串 '11:12:11> 001 enter chatroom, level2'中的用户id和等级
str1 = '11:12:11> 001 enter chatroom, level2'
list1 = str1.split(' ')
level = list1[4]
a = len(level)
print(f'用户ID：{list1[1]}')
print(f'用户等级为:{level[5: a]}')

# 2.获取下面字符串中的所有用户id和等级
# '''11:12:11> 001 enter chatroom, level2
# 11:12:11> 22 enter chatroom, level3
# 11:12:11> 0004 enter chatroom, level105
# 11:12:11> 003 enter chatroom, level99
# '''
str = '''11:12:11> 001 enter chatroom, level2
11:12:11> 22 enter chatroom, level3
11:12:11> 0004 enter chatroom, level105
11:12:11> 003 enter chatroom, level99'''

list1 = str.split('\n')
for i in range(len(list1)):
    lista = list1[i].split(' ')
    level = lista[4]
    uselevel = level[5:len(level)]
    print(f'用户{lista[1]}的等级为{uselevel}')

# 3.将字符串'abcd[0910efg&*(]hijkl[ada2r4545]mn03opq$st'中的非字母字符去掉
str1 = 'abcd[0910efg&*(]hijkl[ada2r4545]mn03opq$st'
str2 = ''
for i in range(len(str1)):
    if str1[i].isalpha():
        str2 += str1[i]
print(str2)

# 5.编写一个程序，要求用户输入一个字符串，将字符串中重复的字符串去除，如输入'abcaadef'，输出为'abcdef'
str1 = 'abcaadef'
for i in range(len(str1)):
    for j in range(len(str1)):
        if str1[i] == str1[j] and i != j:
            break
        elif str1[i] ==str1[j] and i == j:
            print(str1[i],end='')
            break

str2 = ''
for i in str1:
    if i not in str2:
        str2 += i
print(str2)